package com.gmail.RichardNguyenCS;


import java.awt.BorderLayout;
import java.awt.CardLayout;
import java.awt.EventQueue;

import javax.swing.JFrame;
import javax.swing.JMenuBar;
import javax.swing.JPanel;

public final class CmncMain {//make it final so it can't be extended and overwritten

	
	//Frame Master Variables - Shared Amongst All Cards
	private JFrame frameMaster = new JFrame();
	
	//CardLayout Variables - Shared Amongst All Cards
	CardLayout cardLayout;
	private JPanel cardContainer;//uses CardLayout
	private JPanel mainCard = new JPanel();
	final static String MAIN_WINDOW = "CMNC Main";
	//add other cards here
	
	//JMenu Items - Shared Amongst All Cards
	private JMenuBar menuBar = new JMenuBar();
	

	MainGUI mainWindow;
	PasswordGUI passwordWindow;
	
	
	
	
	/**
	 * Launch the application.
	 */
	public static void main(String[] args) {
		EventQueue.invokeLater(new Runnable() {
			public void run() {
				try {
					CmncMain window = new CmncMain();//once password has been validated, start the Master GUI		
						window.passwordWindow = new PasswordGUI(window);//start password GUI
						window.mainWindow = new MainGUI(window);//start the Main GUI
						
								
						
				} catch (Exception e) {
					e.printStackTrace();
				}
			}
		});
	}

	/**
	 * Create the application.
	 */


	/**
	 * Initialize the contents of the frame.
	 */
	
	public CmncMain() {
		initialize();//start the Master GUI
	}
	
	
	private void initialize() {

		//Setup JFrame
		//Note: Use the same Jframe. It's bad practice according to online to use multiple Jframes
		frameMaster = new JFrame();//create a new frame
		frameMaster.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);//set to stop java program on exit with upper right hand X
		
		
		//Setup cardLayout - Shared Amongst All Cards
		cardLayout = new CardLayout();//an imported class from the Java Libraries
		cardContainer = new JPanel(cardLayout);//Setup the card container, pass the card layout object
		cardContainer.add(mainCard, MAIN_WINDOW);//add the cards to the card container
		

		//Attach the cards to the frameMainWindow
		frameMaster.getContentPane().add(cardContainer, BorderLayout.CENTER);
		
		//Show initial card
		cardLayout.show(cardContainer, MAIN_WINDOW);
		
		
	}//end initialize()
	
	public void seeFrame() {
		frameMaster.setVisible(true);	
	}//seeFrame()

	public void hideFrame() {
		frameMaster.setVisible(false);	
	}//seeFrame()
	
	public JFrame getFrame() {
		return frameMaster;
	}//getFrame()
	
	public JMenuBar getMenuBar() {
		return menuBar;
	}//getFrame()
	
	public JPanel getMainCard() {
		return mainCard;
	}//getFrame()


}
